using System;
using System.Security.Cryptography;
using System.Text;

namespace TMS.SocialNews.Core.Classes
{
    public static class GeneralFunctions
    {
        /// <summary>
        /// Generates a SHA1 hash using the string provided.
        /// </summary>
        /// <param name="Data">String to generate the SHA1 has with.</param>
        /// <returns>The SHA1 hash as a Base64 string</returns>
        public static string GenerateSHA1Hash(string Data)
        {
            Encoding encoder = new UTF8Encoding();
            SHA1 sha = new SHA1Managed();
            byte[] DataHash = sha.ComputeHash(encoder.GetBytes("SocialNews" + Data));
            return Convert.ToBase64String(DataHash);
        }
    }
}